<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>闭包和作用域经典面试题</title>
</head>

<body>

</body>

</html>
<script>
    var number = 2;
    var obj = {
        number: 4,
        fn1: (function () {
            this.number *= 2;
            number = number * 2;
            var number = 3;
            return function () {
                console.log(this);
                this.number *= 2;
                number *= 3;
                alert("fn内" + number);
            }
        })()
    };
    var fn1 = obj.fn1;
    alert("全局" + number);
    fn1();
    obj.fn1();
    alert("window.number全局" + window.number);
    alert("obj.number全局" + obj.number);
</script>